1. /* snfblksf.cpp by K.Tsuru */
  2. // function ID = 101
  3. /************************************************************
  4. SNumber auxiliary function
  5. Provides the shift to upper(n>0) or lower(n<0) of FigBlock.
  6. It does not enlarge the size, i.e. cut off an oversize area.
  7. If abs(n) >= a.size(), "a" is initialized by zero.
  8. *************************************************************/
  9. #ifndef SN_H
  10. #include "sn.h"
  11. #endif
  12. int FigBlockShift(FigBlock& a, int n){
  13. if(!n) return 1;
  14. fType* ev = a.Elements();
  15. int mv = (int)a.size() - abs(n);
  16. if( mv <= 0 ){ a.clear(0); return 0; }
  17. if(n > 0){ //shift to upper ev[j+n] <-- ev[j] for 0<= j < a.size() -n = mv
  18. memmove(&ev[n], &ev[0], sizeof(fType)*mv);
  19. a.clear(0, n-1); //clear lower part
  20. } else { //shift to lower ev[j] <-- ev[j+|n|]
  21. n = -n;
  22. memmove(&ev[0], &ev[n], sizeof(fType)*mv);
  23. a.clear(mv); //clear upper part
  24. }
  25. return 1;
  26. }

snfblksf.cpp : last modifiled at 2017/03/13 14:32:01(916 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).